<?php
/**  自动检测发短信的数据库 如果订单下进来 自动发短信
 * Created by PhpStorm.
 * User: KaZeline
 * Date: 15-10-29
 * Time: 下午3:17
 */

require_once("/var/www/html/new/conf/le.je");
$le=new go_sql();
$le->connect();
$soap = new SoapClient(null,array(
        "location" => "http://localhost/open/openService/pft_insideMX.php",
        "uri" => "www.16u.com?ac_16u=16ucom|pw_16u=c33367701511b4f6020ec61ded352059|auth_16u=true")
);
function send_by_ordernum($ordernum=0,$table_id=0){
    if($ordernum+0==0 && $table_id+0==0) return 'fail';
    $where = '';
    if($ordernum+0>0){
        $where .= " ordernum=$ordernum";
        $mark = 1;
    }
    if($table_id+0>0){
        if($mark==1) $where .= 'or ';
        $where .= " id=$table_id";
    }
    $sql = "select id,ordertel,smstxt from sms_order where $where limit 1";
    $GLOBALS['le']->query($sql);
    $row = $GLOBALS['le']->fetch_assoc();
    $ret = $GLOBALS['soap']->Send_SMS_V($row['ordertel'],$row['smstxt']);
    if($ret==100) return 'success';
    return 'fail';
}

//echo send_by_ordernum(2754023);
$le->close();